import {
    homeApi,
    searchWindowApi,
    clearnHistoryApi,
    loginOrRegApi,
    realtimeSearchApi,
    getGoodsListApi,
    getGoodsDetailApi,
    getRelatedGoodsApi,
    getCartTagDataApi,
    addToCartApi,
    categoryApi,
    categoryCurrentPageApi,
    zhuantiDataApi,
    getCartDataApi,
    checkGoodsApi,
    deleteGoodsApi,
    goodsStepApi

} from "./api";
import {
    fetch
} from "./fetch";

//获取首页数据
export function getHomeData() {
    return fetch({
        url: homeApi
    });
}
// 获取搜索页面数据
export function getSearchWindowData() {
    return fetch({
        url: searchWindowApi
    });
}
//清除历史记录
export function clearnHistoryData() {
    return fetch({
        url: clearnHistoryApi,
        method: "POST",

    });
}
//登录或注册
export function loginOrReg(data) {
    return fetch({
        url: loginOrRegApi,
        method: "POST",
        data: data
    });
    520
}
//实时搜索
export function searchCurrent(keyword) {
    return fetch({
        url: realtimeSearchApi,
        method: "GET",
        data: {
            keyword: keyword
        }
    });
}
//搜索显示商品列表接口
export function getgoodsList(data) {
    return fetch({
        url: getGoodsListApi,
        method: "GET",
        data: data
    });
}
//获取商品详细接口
export function getgoodsDetail(goodsid) {
    return fetch({
        url: getGoodsDetailApi,
        method: "GET",
        data: {
            id: goodsid
        }
    });
}
//获取商品详细接口
export function getRelatedGoods(goodsid) {
    return fetch({
        url: getRelatedGoodsApi,
        method: "GET",
        data: {
            id: goodsid
        }
    });
}
//获取购物车数据
export function getCartTagData() {
    return fetch({
        url: getCartTagDataApi,
        method: "GET",

    });
}
//加入购物车接口
export function addToCart(data) {
    return fetch({
        url: addToCartApi,
        method: "POST",
        data: data

    });
}
//分类页面数据接口
export function categoryData(data) {
    return fetch({
        url: categoryApi,
        method: "GET",
    });
}
//分类当前页数据
export function categoryCurrentPageData(id) {
    return fetch({
        url: categoryCurrentPageApi,
        method: "GET",
        data: {
            id: id
        }
    });
}
//专题数据接口
export function getZhuantiData(data) {
    return fetch({
        url: zhuantiDataApi,
        method: "GET",
        data: data
    });
}
//获取购物车数据接口、
export function getCartData() {
    return fetch({
        url: getCartDataApi,
        method: "GET",

    });
}
//点击切换商品选中状态接口
export function checkGoodsData(data) {
    return fetch({
        url: checkGoodsApi,
        method: "POST",
        data: data
    });
}
//删除商品
export function deletetGoodsData(goodsid) {
    return fetch({
        url: deleteGoodsApi,
        method: "POST",
        data: {
            productIds: goodsid
        }
    });
}
//商品步进器
export function goodsSteptepData(data) {
    return fetch({
        url: goodsStepApi,
        method: "POST",
        data: data,
        header: {
            'X-Nideshop-Token': wx.getStorageSync('token'),
            'Content-type': 'application/json;charset=utf-8'
        }
    });
}